﻿<UserControl x:Class="MouseExtender.Controls.UserControls.TabsUC"
						 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
						 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
						 xmlns:logic="clr-namespace:MouseExtender.Logic"
						 xmlns:common="clr-namespace:MouseExtender.Logic.Common"
						 Height="20" Margin="9,1,0,0" ClipToBounds="True" Loaded="UserControl_Loaded">
	<UserControl.ContextMenu>
		<ContextMenu>
			<MenuItem Command="common:Commands.AddTab"/>
			<MenuItem Command="common:Commands.AddFile"/>
			<MenuItem Command="common:Commands.AddFolder"/>
			<MenuItem Command="common:Commands.AddUrl"/>
			<MenuItem Command="common:Commands.AddRunningProgram"/>
			<Separator/>
			<MenuItem Command="common:Commands.Disable" x:Name="miDisable"/>
			<MenuItem Command="common:Commands.ShowSettings"/>
			<MenuItem Command="common:Commands.CheckUpdates"/>
			<MenuItem Command="common:Commands.About"/>
			<MenuItem Command="common:Commands.Exit"/>
		</ContextMenu>
	</UserControl.ContextMenu>
	<UserControl.Resources>
		<Style TargetType="{x:Type ListBoxItem}">
			<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
		</Style>
		<Style x:Key="TabStyle" TargetType="Button">
			<Setter Property="Focusable" Value="False"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<Rectangle x:Name="tabHitArea" Grid.Column="0" Height="18" Width="16" Fill="Transparent" Margin="-1" SnapsToDevicePixels="True"/>
							<Rectangle x:Name="tabThumb" Grid.Column="0" Height="14" Width="12" SnapsToDevicePixels="True" Margin="1,0,1,0">
								<Rectangle.Fill>
									<DrawingBrush Stretch="Uniform">
										<DrawingBrush.Drawing>
											<GeometryDrawing>
												<GeometryDrawing.Geometry>
													<GeometryGroup>
														<PathGeometry Figures="M 9,0 L 12,3"/>
														<PathGeometry Figures="M 4,0 L 12,8"/>
														<PathGeometry Figures="M 0,1 L 12,13"/>
														<PathGeometry Figures="M 0,6 L 8,14"/>
														<PathGeometry Figures="M 0,11 L 3,14"/>
													</GeometryGroup>
												</GeometryDrawing.Geometry>
												<GeometryDrawing.Pen>
													<Pen x:Name="thumbPen" Brush="{x:Static logic:TabColors.DefaultColorBrush}" Thickness="2"/>
												</GeometryDrawing.Pen>
											</GeometryDrawing>
										</DrawingBrush.Drawing>
									</DrawingBrush>
								</Rectangle.Fill>
							</Rectangle>
							<TextBlock x:Name="tabTitle" Uid="{Binding Path=Id}" Grid.Column="1" Foreground="{TemplateBinding Background}" FontSize="12" Margin="0" IsHitTestVisible="False" Loaded="tabTitle_Loaded">
								<ContentPresenter Margin="0"/>
							</TextBlock>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>
	<Grid>
		<ListBox x:Name="tabs" Background="Transparent" BorderThickness="0" Height="20" Focusable="True" FocusVisualStyle="{x:Null}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
			<ListBox.Style>
				<Style>
					<Style.Resources>
						<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
						<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
					</Style.Resources>
				</Style>
			</ListBox.Style>
			<ListBox.ItemsPanel>
				<ItemsPanelTemplate>
					<StackPanel Orientation="Horizontal"/>
				</ItemsPanelTemplate>
			</ListBox.ItemsPanel>
			<ListBox.ItemTemplate>
				<DataTemplate>
					<Button Content="{Binding Path=Name}" Uid="{Binding Path=Id}" Style="{StaticResource TabStyle}" Click="Button_Click" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave">
						<Button.Background>
							<SolidColorBrush Color="{Binding Path=Color}"/>
						</Button.Background>
						<Button.ContextMenu>
							<ContextMenu>
								<MenuItem Command="common:Commands.EditTab" CommandParameter="{Binding Path=Id}"/>
								<MenuItem Command="common:Commands.RemoveTab" CommandParameter="{Binding Path=Id}"/>
								<MenuItem Command="common:Commands.AddTab"/>
								<Separator/>
								<MenuItem Command="common:Commands.AddFile"/>
								<MenuItem Command="common:Commands.AddFolder"/>
								<MenuItem Command="common:Commands.AddRunningProgram"/>
								<Separator/>
								<MenuItem Command="common:Commands.ShowSettings"/>
								<MenuItem Command="common:Commands.CheckUpdates"/>
								<MenuItem Command="common:Commands.About"/>
								<MenuItem Command="common:Commands.Exit"/>
							</ContextMenu>
						</Button.ContextMenu>
					</Button>
				</DataTemplate>
			</ListBox.ItemTemplate>
		</ListBox>
	</Grid>
</UserControl>
